package net.hn.hnms.biz.plan.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.hn.hnms.biz.plan.domain.ExecutionWashing;
import net.hn.hnms.biz.plan.vo.ExecutionWashingVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface ExecutionWashingMapper extends BaseMapper<ExecutionWashing> {

    @Select("<script>" +
            " select  " +
            " sum(washing_amount) as totalWashingAmount, " +
            " sum(shale_amount) as totalShaleAmount, " +
            " sum(coal_amount) as totalCoalAmount " +
            " from execution_washing  " +
            " where del_flag ='0' and  mine_code = #{mineCode} " +
            "</script>")
    ExecutionWashingVO selectExecutionWashingTotalByMineCode(@Param("mineCode") String mineCode);


    @Select("<script>" +
            " select  " +
            " washing_amount as totalWashingAmount, " +
            " shale_amount as totalShaleAmount, " +
            " coal_amount as totalCoalAmount " +
            " from execution_washing  " +
            " where del_flag ='0' AND DATE_TRUNC('day', execution_date) = CAST( #{date} AS TIMESTAMP)  and  mine_code = #{mineCode} " +
            "</script>")
    ExecutionWashingVO selectByDate(@Param("mineCode") String mineCode,@Param("date") String date);


    @Select("<script>" +
            " select  " +
            " sum(washing_amount) as totalWashingAmount, " +
            " sum(shale_amount) as totalShaleAmount, " +
            " sum(coal_amount) as totalCoalAmount " +
            " from execution_washing  " +
            " where del_flag ='0' and  company_code = #{mineCode} " +
            "</script>")
    ExecutionWashingVO selectExecutionWashingTotalByCompanyCodeOrName(@Param("mineCode") String mineCode);
}
